Skip to content

ColorConverter non-initialization memory fix#7610

Closed
gamblor21 wants to merge 17 commits into
adafruit:mainfrom
gamblor21:colorconverter_mem_fix
Closed

ColorConverter non-initialization memory fix#7610
gamblor21 wants to merge 17 commits into
adafruit:mainfrom
gamblor21:colorconverter_mem_fix

Conversation

@gamblor21
Copy link
Copy Markdown
Member

Fix for #7609

The output colorspace struct was created every call to convert but the structure was not initialized leading to random values. Specifically reverse_bytes_in_word was referenced in the conversion function with never being set. This lead to unpredictable behavior.

Moved the colorspace object to the class structure so it can be reused and is properly initialized. This also allows the output colorspace to be made to be configurable in the future.

Tested on a KB2040.

import displayio
cc = displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB888)
hex(cc.convert(0x00ff00))

Should return 0x7e0
Before would randomly return 0xe007

@gamblor21
Copy link
Copy Markdown
Member Author

Messed up and included my GIF PR in this. Will resubmit, don't have time to fight with git.

@gamblor21 gamblor21 closed this Feb 18, 2023
@gamblor21 gamblor21 deleted the colorconverter_mem_fix branch February 18, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant